home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.01 Jan 90 / DLL Source Code / SampBBB.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-27  |  2.3 KB  |  83 lines  |  [TEXT/MPS ]

  1. /************************************************/
  2. /*                  Sample DLL's                */
  3. /*       Copyright © Vincent Parsons 1989.      */
  4. /************************************************/
  5. /*    DLL code for MPW C 3.0 or THINK C 4.0     */
  6. /*       with Excel for the Macintosh 2.2       */
  7. /*             and Microsoft C 5.1              */
  8. /*          with Excel for Windows 2.1          */
  9. /************************************************/
  10. /* SampBBB is an example of two data type B     */
  11. /* inputs and one data type B output.  The      */
  12. /* output is the product of the two inputs.     */
  13. /************************************************/
  14. /*   =REGISTER("SampDLLs","SampBBB","BBB")      */
  15. /*   for both the Mac and the PC.               */
  16. /************************************************/
  17. /* 
  18.    Note that the floating point numbers 
  19.    are passed as double64 * on the Mac and 
  20.    double64 on the PC.
  21.    
  22.    The function type is pascal double64 * on the 
  23.    Mac and double64 far * far pascal on the PC.
  24.    
  25.    On the Mac the returned value is d1 (a pointer 
  26.    to the double64 result) and the answer has been 
  27.    stored in the Excel buffer used by the input 
  28.    variable.
  29.    
  30.    On the PC the answer is stored in a static 
  31.    variable and the returned value is a pointer 
  32.    to that static value.
  33.    
  34.    This was done so the REGISTER command is the 
  35.    same in the PC and the Mac.
  36. */
  37. /************************************************/
  38.  
  39. #include "DLL.h"
  40.  
  41. #if applec
  42. #include <Types.h>
  43.  
  44. #elif MSDOS
  45. #include <windows.h>
  46.  
  47. #endif
  48.  
  49. #if THINK_C
  50. pascal double64 * main(double64 * d1, double64 * d2);    /* prototype */
  51.  
  52. pascal double64 * main(d1, d2)
  53. double64 * d1;
  54. double64 * d2;
  55.  
  56. #elif applec
  57. pascal double64 * SampBBB(double64 * d1, double64 * d2)
  58.  
  59. #elif MSDOS
  60. double64 far * far pascal SampBBB(double64 d1, double64 d2)
  61. #endif
  62. {
  63. #if applec | THINK_C
  64.     double64 answer;
  65.     
  66.     /* Returned parameter is the product of the two inputs */
  67.     answer = *d1 * *d2;
  68.     *d1 = answer;    /* Store value in Excel data buffer since static */
  69.     return ( d1 );    /* variables are not permitted in Mac code resources */
  70.  
  71. #elif MSDOS
  72.     static double64 answer;
  73.     
  74.     /* Returned parameter is the product of the two inputs */
  75.     answer = d1 * d2;
  76.     return ( (double64 far *)&answer );
  77.  
  78. #endif
  79. }
  80.  
  81. /************************************************/
  82.  
  83.